<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>阻止冒泡事件向上传递</title>
</head>
<style>
    html{
        background-color: #369;
    }
</style>
<body>
    <div id="father">
        <button>点我</button>
    </div>
</body>
</html>

<script type="text/javascript">
    var button = document.getElementsByTagName("button")[0];
    button.onclick = function (e) {
        var event = e || window.event;
        alert(123);
        //w3c  标准   event.stopPropagation()
        //ie 6 7 8         event.cancelBubble = true
       event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
    }

    document.documentElement.onclick = function () {
        alert("这是HTML!")
    }
</script>